package com.zxd.clones;

import java.util.Arrays;

/**
 * ClassName:Students
 * Package:com.zxd.clones
 *
 * @Date:2023/9/22 14:36
 * @Author:zxde
 */
//Cloneable是一个标记接口
public class Students implements Cloneable {
    private String name;
    private int age;
    private Double[] score;

    public Students(String name, int age, Double[] score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    public Students() {

    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Double[] getScore() {
        return score;
    }

    public void setScore(Double[] score) {
        this.score = score;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Students s = (Students) super.clone();
        //深拷贝，将原来对象的引用数据类型进行clone
        s.setScore(s.getScore().clone());
        return s;
    }

    @Override
    public String toString() {
        return "Students{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + Arrays.toString(score) +
                '}';
    }
}
